// packageE/memberasset/memberasset.js
var app = getApp();
Component({
  properties: {
    datas: {
      type: null,
    },
    other: {
      type: null,
    }
  },
  // 私有数据，可用于模板渲染
  data: {
    newDatas: {
      show_list: [],
      couponCount:0
    }
  },
  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached() {
    },
    moved() { },
    detached() { },
  },

  // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
  attached() { },
  // 此处attached的声明会被lifetimes字段中的声明覆盖
  ready() {
     this.getAccountCoupon();
  },

  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show() { },
    hide() { },
    resize() { },
  },
  methods: {
    getAccountCoupon() {
      let urlStr = app.getNetAddresss("coupon.member-coupon.coupons-count-of-member");
      let self = this;
      app._getNetWork({
        url: urlStr,
        data: {
          v: 2,
          basic_info: 1
        },
        success: (resdata) => {
          var res = resdata.data;
          if (res.result === 1) { 
             self.setData({
               couponCount:res.data
             })
          }
        }
      })
    },
    toUrl(e) {
      let _data = e.currentTarget.dataset || {};
      this.wxRouterLink(_data);
    },
    toUrl1(e) {
      wx.navigateTo({
        url: `/packageA/member/coupon_v2/coupon_v2`
      });
    },
    
    wxRouterLink(_data) {
      let _Param = "";
      const { url, ...otherParam } = _data;
      Object.keys(otherParam).forEach(function (key) {
        if (otherParam[key] !== "") _Param += key + "=" + otherParam[key] + "&";
      });
      if (url === "") return;
      wx.navigateTo({
        url: url + "?" + _Param.slice(0, -1),
      });
    },
  },
});
